package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	SellOrderProductEventNew           = "erp.SellOrderProductNew"
	SellOrderProductEventBeforeCreate  = "erp.SellOrderProductBeforeCreate"
	SellOrderProductEventBeforeUpdate  = "erp.SellOrderProductBeforeUpdate"
	SellOrderProductEventBeforeSave    = "erp.SellOrderProductBeforeCreate erp.SellOrderProductBeforeUpdate"
	SellOrderProductEventAfterCreate   = "erp.SellOrderProductAfterCreate"
	SellOrderProductEventAfterUpdate   = "erp.SellOrderProductAfterUpdate"
	SellOrderProductEventAfterSave     = "erp.SellOrderProductAfterCreate erp.SellOrderProductAfterUpdate"
	SellOrderProductEventDelete        = "erp.SellOrderProductDelete"
	SellOrderProductAccessControlEvent = "erp.SellOrderProductAccessControl"
)

func GetSellOrderProductConfig() *mgo.DocConfig {
	return SellOrderProduct_Config
}

var SellOrderProduct_Config *mgo.DocConfig

func init() {
	SellOrderProduct_Config = NewSellOrderProductConfig()
}
func NewSellOrderProductConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.SellOrderProduct",
		Fields: []string{
			"belongTo", "src", "srcSN", "product", "num", "unit", "price", "money", "cut", "cutRate", "tax", "taxRate", "priceRef", "moneyRef", "priceConfirm", "moneyConfirm", "note", "row",
		},
		RelationFields: []string{
			"belongTo", "product", "unit", "taxRate",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"belongTo": {
				Config:     GetSellOrderConfig,
				DocName:    "SellOrder",
				JoinType:   "O",
				KeyInside:  "belongToId",
				KeyOutSide: "id",
			},
			"product": {
				Config:     GetProductConfig,
				DocName:    "Product",
				JoinType:   "O",
				KeyInside:  "productId",
				KeyOutSide: "id",
			},
			"unit": {
				Config:     GetUnitConfig,
				DocName:    "Unit",
				JoinType:   "O",
				KeyInside:  "unitId",
				KeyOutSide: "id",
			},
			"taxRate": {
				Config:     GetTaxRateConfig,
				DocName:    "TaxRate",
				JoinType:   "O",
				KeyInside:  "taxRateId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
